<?php

namespace App\Http\Controllers;

use Exception;
use Iamxcd\LaravelCRUD\Traits\HasResponse;
use Illuminate\Routing\Controller;
use Mews\Captcha\Captcha;

class CaptchaController extends Controller
{
    use HasResponse;

    /**
     * get CAPTCHA api
     *
     * @param Captcha $captcha
     * @param string $config
     * @return array|mixed
     * @throws Exception
     */
    public function getCaptchaApi(Captcha $captcha, string $config = 'math')
    {
        return $this->response([
            'captcha' => $captcha->create($config, true)
        ]);
    }
}
